using System;
using BitMango.Diagnostics;
using Holoville.HOTween;
using Holoville.HOTween.Plugins;
using UnityEngine;

public class CoinHandler : MonoBehaviour, IWidget, IHandlerBase
{
	public void SetData(Vector3 _targetPosition, float _scale, float _destScale, int _coinCount, Action<int> _callback)
	{
		this.targetPosition = _targetPosition;
		this.scale = _scale;
		this.destScale = _destScale;
		this.coinCount = _coinCount;
		this.callback = _callback;
		this.DoDataExchange();
	}

	public void DoDataExchange()
	{
		float p_duration = 1.5f;
		Vector3[] array = new Vector3[3];
		Vector3 vector = base.transform.position + Vector3.back * 10f;
		Vector3 vector2 = this.targetPosition + Vector3.back * 10f;
		array[0] = vector;
		array[1] = new Vector3(UnityEngine.Random.Range(vector.x, vector.x + 5f), vector.y, vector.z) + Vector3.back * 10f;
		array[2] = vector2;
		Sequence sequence = new Sequence(new SequenceParms().OnComplete(delegate()
		{
			Debugger.Assert(this != null, "BubbleScoreHandler  == null");
			if (this.callback != null)
			{
				this.callback(this.coinCount);
			}
			if (this != null)
			{
				UnityEngine.Object.Destroy(base.gameObject);
			}
		}));
		sequence.Insert(0f, HOTween.To(base.gameObject.transform, p_duration, new TweenParms().Prop("localScale", Vector3.one * this.destScale)));
		sequence.Insert(0f, HOTween.To(base.gameObject.transform, p_duration, new TweenParms().Prop("position", new PlugVector3Path(array, PathType.Curved))));
		sequence.Play();
	}

	public tk2dSprite icon;

	private Vector3 targetPosition;

	private Action<int> callback;

	private int coinCount = 1;

	private float scale = 1f;

	private float destScale = 1f;
}
